﻿<!-- #include file="cjf.asp" -->
<!--#include file="conn.asp"-->
<!--#include file="inc/CHAR.INC"-->
<%
cjid=request("cjid")
set rs=server.CreateObject("ADODB.RecordSet")
sql="select * from cjxm where id="&cjid
rs.open sql,conn,1,3
xmmc=rs("xmmc")
xmfd=rs("xmfd")
xmsx=rs("xmsx")
cjurl=rs("cjurl")
fnbody=rs("fnbody")
fnfg=rs("fnfg")
fnid=rs("fnid")
fnmc=rs("fnmc")
mhurl=rs("mhurl")
rs.close
if request("cjurl")="" then
cjurl=cjurl
else
cjurl=request("cjurl")
end if%><html>
<head>
    <title>漫画采集</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <link href="images/style.css" type="text/css" rel="stylesheet">
    <script language="JavaScript" src="inc/js.js" type="text/javascript"></script>
    <style type="text/css">
<!--
.STYLE1 {color: #999999}
-->
</style>
</head>
<body>
    <center>
        <table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC">
            <tr>
                <td height="30" bgcolor="e7e7e7">
                    <div align="left">
                        <strong>
                            <%=xmmc%>数据采集 </strong>
                    </div>
                </td>
            </tr>
            <form action="" method="get" name="formcj">
            <input name="act" type="hidden" value="cj">
            <input name="cjid" type="hidden" value="<%=request("cjid")%>">
            <tr>
                <td bgcolor="#FFFFFF">
                    &nbsp;采集地址(采集列表页的URL地址)：
                    <input name="cjurl" type="text" value="<%=cjurl%>" size="50">
                    <input name="submit" type="submit" <%if xmsx<>1 then%>disabled<%end if%> class="Submit"
                        value="开始采集">
                </td>
            </tr>
            </form>
            <form action="" method="get" name="formcj">
            <tr>
                <td height="30" bgcolor="#FFFFFF">
                    &nbsp;输入ID号采集:
                    <input name="act" type="hidden" value="cj2">
                    <input name="cjid" type="hidden" value="<%=request("cjid")%>">
                    ID1
                    <input name="id1" type="text" id="id1" size="10">
                    至 ID2
                    <input name="id2" type="text" id="id2" size="10">
                    <input name="submit2" type="submit" class="Submit" value="开始采集">
                </td>
            </tr>
            </form>
        </table>
        <table width="98%" border="0" align="center" cellpadding="8" cellspacing="1" bgcolor="#CCCCCC"
            style="margin-top: 5px">
            <tr>
                <td width="100%" colspan="3" bgcolor="#FFFFFF">
                    <%if request("act")="cj" then%>
                    <%
Server.ScriptTimeOut=99999
cjid=request("cjid")
url=request("cjurl")
if url="" then
   Response.write "&nbsp;请输入列表页地址&nbsp;&nbsp;<A HREF=# onclick=""Javascript:history.back(-1)""><FONT  COLOR=#FF0000>请点这里返回</FONT></A>"
   Response.End
end if
   Caijimake
Sub Caijimake

MakeIMG
End Sub

Sub MakeIMG
Dim k:k=0




url=bqtf1(cjurl)
fnbody=bqtf1(fnbody)
fnfg=bqtf1(fnfg)
fnid=bqtf1(fnid)
fnmc=bqtf1(fnmc)



fnbody1=Split(fnbody,"$")
fnid1=Split(fnid,"$")
fnmc1=Split(fnmc,"$")

zlp=GetHttp(url) 

'采集相关信息开始
body=GetStr(zlp,fnbody1(0),fnbody1(1))
'Response.Write "<textarea>"& body & "</textarea><br>"
'Response.Write "<textarea>"& fnfg & "</textarea><br>"
body2=Split(body,""&fnfg&"")

bodys=ubound(body2) 
'开始写入数据

'===================================================
'RString=DeHttpdata(zlp,"'[^<>'']*','[^<>'']*','[^<>""]*'")
Response.write "<table border=0 width=100% align=center>"
Response.write  "<form method=""post"" name=""form1"" id=""form1""><tr><td width=100% colspan=""5"">"

Response.Write "<b>&nbsp;&nbsp;共找到："&bodys+1&"部漫画</b>"
Response.write "</td></tr>"

response.flush

for i=0 to bodys-1
fnidx=fnidx&i

fnidx=GetStr(body2(i),fnid1(0),fnid1(1))

fnmcx=GetStr(body2(i),fnmc1(0),fnmc1(1))
Response.Write "<textarea>"& fnid1(1) & "</textarea><br>"
if (i mod 3)=0 and i>=3 then
Response.write "<tr>"
end if
Response.Write "<td>"
fnmcx=trim(fnmcx)
if instr(fnmcx,"[")<>0  then
fnmcx2=Split(fnmcx,"[")
fnmcx3=fnmcx2(0)
else
fnmcx3=fnmcx
end if

Sql="Select * From cjlog where mcmc='"&fnmcx3&"'"
Rs.Open Sql,Conn,1,3
if rs.eof then
Rs.AddNew
rs("cjid")=cjid
rs("mcmc")=fnmcx3
rs("mhid")=trim(fnidx)
rs("adddate")=now()
rs.update
rs.close
Response.Write "&nbsp;&nbsp;<font color=red>"&fnidx&"&nbsp;&nbsp;"&fnmcx3&"</font>&nbsp;&nbsp;<td>"
else
Response.Write "&nbsp;&nbsp;"&fnidx&"&nbsp;&nbsp;"&fnmcx3&"<td>"
rs.close
end if
response.flush
if (i mod 3)=0 and i>=3 then
Response.write "</tr>"
end if

next

End Sub

                    %>
                    <%elseif request("act")="cj2" then

	  cjid=request("cjid")
	  id1=request("id1")
	  id2=request("id2")
	  if IsNumeric(id1)=false or IsNumeric(id2)=false then
		  Response.Write "ID号必须为数字&nbsp;&nbsp;<A HREF=# onclick=""Javascript:history.back(-1)""><FONT  COLOR=#FF0000>请点这里返回</FONT></A>"
	  Response.End  
end if
if id2<id1 then
		  Response.Write "ID2必须大于ID1 &nbsp;<A HREF=# onclick=""Javascript:history.back(-1)""><FONT  COLOR=#FF0000>请点这里返回</FONT></A>"
	  Response.End  
	  end if
	  if id2-id1>100 then
		  Response.Write "为保证处理速度，按ID采集请一次不要超过50个漫画&nbsp;<A HREF=# onclick=""Javascript:history.back(-1)""><FONT  COLOR=#FF0000>请点这里返回</FONT></A>"
	  Response.End  
	  end if
	  for i=id1 to id2
sql="select * from cjxm where id="&cjid
rs.open sql,conn,1,3
xmmc=rs("xmmc")
xmfd=rs("xmfd")
xmsx=rs("xmsx")
fnbody=rs("fnbody")
fnfg=rs("fnfg")
fnid=rs("fnid")
fnmc=rs("fnmc")
mhurl=rs("mhurl")
mhbody=rs("mhbody")
mhmc=rs("mhmc")
mhtp=rs("mhtp")
mhtpurl=rs("mhtpurl")
mhzz=rs("mhzz")
mhjs=rs("mhjs")
mhzt=rs("mhzt")
mhfg=rs("mhfg")
mhzj=rs("mhzj")
wj=rs("wj")
lz=rs("lz")
mhzjid=rs("mhzjid")
rs.close
cjurl=Replace(mhurl,"[ID]",""&i&"") 
url=bqtf1(cjurl)
mhbody=bqtf1(mhbody)
mhmc=bqtf1(mhmc)
mhbody1=Split(mhbody,"$")
mhmc1=Split(mhmc,"$")
zlp=GetHttp(url) 

'采集相关信息开始
body=GetStr(zlp,mhbody1(0),mhbody1(1))
mhmc2=GetStr(body,mhmc1(0),mhmc1(1))
mhmc2=Split(mhmc2,"[")
mhmc3=mhmc2(0)

if trim(mhmc3)<>"" then
Sql="Select * From cjlog where mcmc='"&trim(mhmc3)&"'"
Rs.Open Sql,Conn,1,3
if rs.eof then

Rs.AddNew
rs("cjid")=cjid
rs("mcmc")=mhmc3
rs("mhid")=i
rs("adddate")=now()
rs.update
rs.close
Response.Write "<div width=50>&nbsp;&nbsp;"&i&"&nbsp;&nbsp;"&mhmc3&"&nbsp;&nbsp;<font color=red>[新]</font></div>"
else
Response.Write "<div width=50>&nbsp;&nbsp;"&i&"&nbsp;&nbsp;"&mhmc3&"</div>"
rs.close
end if
end if
	  
	  next
                    %><%else%>
                    <span class="STYLE1">正在等待开始采集漫画数据....</span>
                    <%end if%>
                </td>
            </tr>
        </table>
    </center>
</body>
</html>
